import turtle
import math

# 设置画布
screen = turtle.Screen()
screen.title("后羿射日")
screen.bgcolor("skyblue")
screen.setup(width=800, height=600)

# 创建绘图对象
pen = turtle.Turtle()
pen.speed(3)  # 绘图速度：1最慢，10最快，0瞬间完成
pen.hideturtle()

def draw_sun(x, y, radius):
    """绘制太阳"""
    pen.penup()
    pen.goto(x, y)
    pen.pendown()
    
    # 绘制太阳主体
    pen.color("yellow", "orange")
    pen.begin_fill()
    pen.circle(radius)
    pen.end_fill()
    
    # 绘制太阳光芒
    pen.color("yellow")
    for i in range(12):
        pen.penup()
        pen.goto(x, y)
        pen.pendown()
        pen.setheading(i * 30)
        pen.forward(radius + 15)

def draw_houyi():
    """绘制后羿"""
    # 身体
    pen.penup()
    pen.goto(200, -100)
    pen.pendown()
    pen.color("brown")
    pen.pensize(5)
    
    # 躯干
    pen.setheading(90)
    pen.forward(80)
    
    # 头部
    pen.penup()
    pen.goto(200, -10)
    pen.pendown()
    pen.color("peachpuff", "peachpuff")
    pen.begin_fill()
    pen.circle(15)
    pen.end_fill()
    
    # 左臂（拉弓）
    pen.penup()
    pen.goto(200, -40)
    pen.pendown()
    pen.color("brown")
    pen.setheading(135)
    pen.forward(60)
    
    # 右臂（持箭）
    pen.penup()
    pen.goto(200, -40)
    pen.pendown()
    pen.setheading(45)
    pen.forward(50)
    
    # 左腿
    pen.penup()
    pen.goto(200, -100)
    pen.pendown()
    pen.setheading(225)
    pen.forward(50)
    
    # 右腿
    pen.penup()
    pen.goto(200, -100)
    pen.pendown()
    pen.setheading(315)
    pen.forward(50)
    
    # 绘制弓
    pen.penup()
    pen.goto(200 - 60*math.cos(math.radians(45)), -40 - 60*math.sin(math.radians(45)))
    pen.pendown()
    pen.color("saddlebrown")
    pen.pensize(4)
    pen.setheading(180)
    pen.circle(50, 180)
    
    # 绘制箭
    pen.penup()
    pen.goto(200 + 50*math.cos(math.radians(45)), -40 + 50*math.sin(math.radians(45)))
    pen.pendown()
    pen.color("gray")
    pen.pensize(2)
    pen.setheading(180)
    pen.forward(100)
    
    # 箭头
    pen.setheading(160)
    pen.forward(10)
    pen.penup()
    pen.backward(10)
    pen.pendown()
    pen.setheading(200)
    pen.forward(10)

# 绘制9个太阳
sun_positions = [
    (-300, 200), (-200, 220), (-100, 200),
    (-350, 100), (-250, 120), (-150, 100),
    (-300, 0), (-200, 20), (-100, 0)
]

for x, y in sun_positions:
    draw_sun(x, y, 20)

# 绘制后羿
draw_houyi()

# 添加文字
pen.penup()
pen.goto(0, -250)
pen.pendown()
pen.color("black")
pen.write("后羿射日", font=("SimHei", 24, "bold"), align="center")

# 保持窗口打开
turtle.done()
